aboutsummaryrefslogtreecommitdiff
path: root/pages/post/[id].tsx
diff options
context:
space:
mode:
Diffstat (limited to 'pages/post/[id].tsx')
-rw-r--r--pages/post/[id].tsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx
index 4f5acf7..b68b790 100644
--- a/pages/post/[id].tsx
+++ b/pages/post/[id].tsx
@@ -128,7 +128,10 @@ function parseToCRecursive(headings: Array<string>): Array<chapter> {
}
function parseToC(file: Array<string>): Array<chapter> {
- var chapterStrings = file.filter(line => line.startsWith("#"));
+ var fileAsStr = file.join("\n");
+ fileAsStr = fileAsStr.replace(/```.*?```/gs, ""); // filter out code blocks from table of contents
+ var fileAsArr = fileAsStr.split("\n");
+ var chapterStrings = fileAsArr.filter(line => line.startsWith("#"));
return parseToCRecursive(chapterStrings);
}